package net.suncaper.demo.service;

import net.suncaper.demo.domain.Admin;
import net.suncaper.demo.mapper.AdminMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminServiceImpl implements AdminService{
    @Autowired
    private AdminMapper adminMapper;


    @Override
    public int checkAdmin(Admin admin) {
        List<Admin> Admins=adminMapper.selectByName("%" + admin.getAdminname() + "%");
        if(Admins.isEmpty()){
            return 1; //1为用户不存在
        }

        else{
            Admin result=Admins.get(0);

            if(result.getAdminpassword().equals(admin.getAdminpassword()))
            {
                return 2;//2为登录成功
            }
            else
            {
                return 3;//3为用户存在，密码错误
            }
        }
    }
}
